<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		
		<meta charset="utf-8" />
		<title></title>
		<meta name="description" content="overview & stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link href="<%=contextPath %>/static/css/bootstrap.min.css" rel="stylesheet" />
		<link href="<%=contextPath %>/static/css/bootstrap-responsive.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="<%=contextPath %>/static/css/font-awesome.min.css" />
		<link rel="stylesheet" href="<%=contextPath %>/static/css/ace.min.css" />
		<link rel="stylesheet" href="<%=contextPath %>/static/css/ace-responsive.min.css" />
		<link rel="stylesheet" href="<%=contextPath %>/static/css/ace-skins.min.css" />
		<script type="text/javascript" src="<%=contextPath %>/static/js/jquery-1.7.2.js"></script>

<script type="text/javascript">
	$(top.hangge());	
	
	//新增
	function addmenu(){
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="新增角色";
		 diag.URL = '<%=contextPath %>/role/toAdd';
		 diag.Width = 223;
		 diag.Height = 186;
		 diag.CancelEvent = function(){ //关闭事件
			if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				setTimeout("location.reload()",100);
			}
			diag.close();
		 };
		 diag.show();
	}
	
	//修改
	function editmenu(menuId){
		 top.jzts();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="编辑菜单";
		 diag.URL = '<%=contextPath %>/role/toEdit?id='+menuId;
		 diag.Width = 223;
		 diag.Height = 186;
		 diag.CancelEvent = function(){ //关闭事件
			if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				top.jzts(); 
				setTimeout("location.reload()",100);
			}
			diag.close();
		 };
		 diag.show();
	}
	
	//分配资源
	function editTb(menuId){
		 top.jzts();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="资源分配";
		 diag.URL = '<%=contextPath %>/role/openauth?id='+menuId;
		 diag.Width = 250;
		 diag.Height = 500;
		 diag.CancelEvent = function(){ //关闭事件
			if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
				top.jzts(); 
				setTimeout("location.reload()",100);
			}
			diag.close();
		 };
		 diag.show();
	}
	
	function delmenu(menuId){
		if(confirm("确定要删除该角色吗？")){
			var url = "<%=contextPath %>/role/del?id="+menuId+"&guid="+new Date().getTime();
			$.get(url,function(data){
				document.location.reload();
			});
		}	
	}
</script>
</head>

<body>
	<table id="table_report" class="table table-striped table-bordered table-hover">
		<thead>
		<tr>
			<th class="center"  style="width: 50px;">序号</th>
			<th class='center'>角色名称</th>
			<th class='center'>角色类型</th>
			<th class='center'>角色描述</th>
			<th class='center'>操作</th>
		</tr>
		</thead>
		<c:choose>
			<c:when test="${not empty role}">
				<c:forEach items="${role}" var="menu" varStatus="vs">
					<tr id="tr${menu.id }">
						<td class="center">${vs.index+1}</td>
						<td class='center'>${menu.name }</td>
						<td class='center'>${fns:getDictLabel(menu.roleType,'role_type','')}</td>
						<td class='center'>${menu.description }</td>
						<td style="width: 25%;"  class='center'>
							<a class='btn btn-mini btn-purple' title="分配资源" onclick="editTb('${menu.id }')" ><i class='icon-pencil'></i>分配资源</a>
							<a class='btn btn-mini btn-info' title="修改" onclick="editmenu('${menu.id }')" ><i class='icon-edit'></i></a>
							<a class='btn btn-mini btn-danger' title="删除"  onclick="delmenu('${menu.id }')"><i class='icon-trash'></i></a>
						</td>
					</tr>
				</c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
				<td colspan="100">没有相关数据</td>
				</tr>
			</c:otherwise>
		</c:choose>
	</table>
	
	<div class="page_and_btn">
		<div>
			&nbsp;&nbsp;<a class="btn btn-small btn-success" onclick="addmenu();">新增</a>
		</div>
	</div>
	
</body>
</html>